import createStore, { IPreact } from "ipreact-for-react";
import { BaseInfo, ChatRoom, LoginUser } from "../serve/interfaces";
import { __VERSION__ } from "./common";
import type { SimpleUser } from "./apis";

export interface IStoreState {
  loginUser?: LoginUser;
  userMap?: Map<SimpleUser["username"], SimpleUser>;
  chatrooms?: (ChatRoom & BaseInfo)[];
  image?: string;
}

const { connect, dispatch, getState }: IPreact<IStoreState> = createStore<IStoreState>([])({});

export { connect, dispatch, getState };
